﻿using System;
using System.Collections.Generic;
using System.Data;
using KillBill.Business.Entities;
using KillBill.Presentarion.Common.Printing.Invoice;
namespace KillBill.Presentation.Modules.Sales
{
    public class BillingPrinter
    {
        public static void PrintBill(int number, Person customer,Dictionary<string,Detail> detail, decimal subtotal, decimal iva, decimal ice, decimal total)
        {
            var printer = new InvoicePrinter();
            var printDetail = new DataTable();
            var clientInformation = new Dictionary<string, string>();
            #region printDetail
            printDetail.Columns.Add("Código");
            printDetail.Columns.Add("Cantidad");
            printDetail.Columns.Add("Detalle");
            printDetail.Columns.Add("V. Unitario");
            printDetail.Columns.Add("V. Total");
            foreach (var detail1 in detail)
            {
                printDetail.Rows.Add(new object[] {detail1.Key,detail1.Value.Quantity,detail1.Value.Product.Name,detail1.Value.Product.LastPrice,detail1.Value.TotalValue});
            }
            #endregion
            #region clientInformation
            clientInformation.Add("Cédula/RUC",customer.PersonID);
            clientInformation.Add("Nombre", customer.FirstName + " " + customer.LastName);
            clientInformation.Add("Dirección",customer.Address);
            clientInformation.Add("Teléfono",customer.Phone);
            #endregion

            printer.PrintDocument(
                (number!=null)?number:0,
                printDetail,
                clientInformation,
                new int[]{2,2,5,3,3},
                false,
                Convert.ToDouble(subtotal),
                Convert.ToDouble(iva),
                Convert.ToDouble(ice),
                Convert.ToDouble(total)
                );
        }
    }
}
